package com.example.permission.service.impl;

import com.example.permission.dao.BaseMapper;
import com.example.permission.dao.RoleMapper;
import com.example.permission.dao.UserMapper;
import com.example.permission.service.RoleService;
import com.example.permission.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色服务层实体类
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<com.example.permission.entity.Role> implements RoleService {

    @Autowired
    private RoleMapper roleMapper;


    @Override
    protected BaseMapper<com.example.permission.entity.Role> baseMapper() {
        return roleMapper;
    }

    @Override
    public List<Integer> getPermissionIdsByRoleId(Integer userId) {
        return roleMapper.getPermissionIdsByRoleId(userId);
    }

    @Override
    public Integer addPermissionIdByRoleId(Integer permissionId, Integer roleId) {
        return roleMapper.addPermissionIdByRoleId(permissionId,roleId);
    }

    @Override
    public Integer removePermissionIdByRoleId(Integer id, Integer permissionId) {
        return roleMapper.removePermissionIdByRoleId(id,permissionId);
    }


}
